from huggingface_hub import hf_hub_download as original_hf_hub_download
import functools

def patched_hf_hub_download(*args, **kwargs):
    print("patched_hf_hub_download")
    if "local_files_only" not in kwargs:
        kwargs["local_files_only"] = True
        print("Patch: local_files_only=True")
    
    return original_hf_hub_download(*args, **kwargs)

def apply_patch():
    from huggingface_hub import hf_hub_download
    if hf_hub_download.__name__ != "patched_hf_hub_download":
        import huggingface_hub
        huggingface_hub.hf_hub_download = patched_hf_hub_download
        print("Patch applied: hf_hub_download")
    
apply_patch()
